<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>LB-Admin1.0</title>
        {include file="header"}
    </head>
    <body>
    <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <form class="layui-form layui-card" method="post" autocomplete="off">
                                <div class="layui-card-body">                            
                                    <div class="layui-form-item">
                                        <label class="layui-form-label label-required-next">栏目级别</label>
                                        <div class="layui-input-block">
                                            <select name='pid' class='layui-select' lay-search>
                                                <option value='0'>顶级栏目</option>
                                                {foreach $menus as $menu}
                                                {eq name='menu.id' value='$vo.pid|default=0'}
                                                <option selected value='{$menu.id}'>{$menu.title}</option>
                                                {else}
                                                <option value='{$menu.id}'>{$menu.title}</option>
                                                {/eq}
                                                {/foreach}
                                            </select>
                                            <p class="help-block">必选，请选择上级菜单或顶级菜单（目前最多支持三级菜单）</p>
                                        </div>
                                    </div>
                            
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">权限名称</label>
                                        <div class="layui-input-block">
                                            <input name="title" value='{$vo.title|default=""}' required placeholder="请输入菜单名称" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">应用名称</label>
                                        <div class="layui-input-block">
                                            <input name="appname" required placeholder="请输入应用名称" value="{$vo.appname|default=''}" class="layui-input">                                           
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">控制器名称</label>
                                        <div class="layui-input-block">
                                            <input name="controller" required placeholder="请输入控制器名称" value="{$vo.controller|default=''}" class="layui-input">                                           
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">方法名称</label>
                                        <div class="layui-input-block">
                                            <input name="method" required placeholder="请输入方法名称" value="{$vo.method|default=''}" class="layui-input">                                           
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">链接参数</label>
                                        <div class="layui-input-block">
                                            <input name="params" placeholder="请输入链接参数" value="{$vo.params|default=''}" class="layui-input">
                                            <p class="help-block">可选，设置菜单链接的GET访问参数（如：name=1&age=3）</p>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">排序</label>
                                        <div class="layui-input-block">
                                            <input name="sort" placeholder="请输入排序数字" value="{$vo.sort|default='0'}" class="layui-input">                                           
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">内容形式</label>
                                        <div class="layui-input-block">
                                            <select name="sigle_page">
                                                <option value="0"{if $vo.sigle_page==0} selected=""{/if}>=选择=</option>
                                                <option value="2"{if $vo.sigle_page==2} selected=""{/if}>列表</option>
                                                <option value="1"{if $vo.sigle_page==1} selected=""{/if}>单页</option>
                                            </select>                                        
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">状态</label>
                                        <div class="layui-input-block">
                                            <input type="checkbox" name="status" value="1"  lay-text="显示|隐藏" checked="" lay-skin="switch">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">图标</label>
                                        <div class="layui-input-block">
                                            <div class="layui-input-inline">
                                                <input placeholder="请输入或选择图标" name="icon" value='{$vo.icon|default=""}' class="layui-input">
                                            </div>
                                            <span style="padding:0 12px;min-width:45px" class='layui-btn layui-btn-primary'>
                                                <i style="font-size:1.2em;margin:0" id="view_icon" class='{$vo.icon|default=""}'></i>
                                            </span>
                                            <button data-icon='icon' type='button' class='layui-btn layui-btn-primary'>选择图标</button>
                                        </div>
                                    </div>
                            
                                </div>
                            
                                <div class="hr-line-dashed"></div>
                                {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
                            
                                <div class="layui-form-item text-center">
                                    <div class="layui-input-block">
                                    <input type="hidden" name="id" value="{$vo.id}">
                                    <button class="layui-btn" type='button' onclick="save()">保存数据</button>
                                    <button class="layui-btn layui-btn-danger" type='button' onclick="closelayer()">关闭</button>
                                    </div>
                                </div>
                            
                            </form>
                            
</div>
<script>
    function closelayer()
    {
        parent.layer.closeAll();
    }
    function save()
    {        
        var formdata=$('form').serializeArray();
        console.log(formdata)
       
        $.post('{:request()->url()}',formdata,function(res){
            console.log(res)
            if(res.code==1)
            {
                parent.location.reload();
                parent.layer.close();
            }
            layer.open('保存失败')
        })
    }
var url = location.href;
layui.use(['form'], function(){
  var form = layui.form;
  layui.form.render();  
});
$(function(){
    $("input[name='icon']").change(function(){
        $("#view_icon").toggleClass($(this).val());
    })
    $(".layui-btn-primary").click(function(){
        layer.open({
            title:'select icon',
            type:2,
            area:['100%','100%'],
            content:'icon.html'
        })
    })
})
</script>
</div></div></div></div>
{include file="footer"}